﻿@model N03_11HCA_HTTTHD.Models.Admin_QuanLyNguoiDung
@{
    ViewBag.Title = "Ban quản trị";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}

@section TimKiemImport{
    <div class="filtering">
    <label for="tenDangNhap">Tên đăng nhập: </label>
        <input type="text" name="tenDangNhap" id="tenDangNhap" />
        <label for="hoTen">Họ tên: </label>
        <input type="text" name="hoTen" id="hoTen" />
        <label for="Email">Email: </label>
        <input type="text" name="Email" id="Email" />
        <label for="DienThoai">Điện thoại: </label>
        <input type="text" name="DienThoai" id="DienThoai" />
        <label for="loaiThanhVien">Loại thành viên: </label>
        <select id="loaiThanhVien" name="loaiThanhVien">
            <option selected="selected" value="0">Tất cả</option>
            @for (int i = 0; i < Model.LoaiLoaiThanhVien.Count; i++)
            {
                <option value="@Model.LoaiLoaiThanhVien[i].ID">@Model.LoaiLoaiThanhVien[i].TenLoaiThanhVien</option>
            }
        </select>
        <label for="loaiTaiKhoan">Loại tài khoản: </label>
        <select id="loaiTaiKhoan" name="loaiTaiKhoan">
            <option selected="selected" value="0">Tất cả</option>
            @for (int i = 0; i < Model.ListLoaiTaiKhoan.Count; i++)
            {
                <option value="@Model.ListLoaiTaiKhoan[i].ID">@Model.ListLoaiTaiKhoan[i].TenLoaiTaiKhoan</option>
            }
        </select>
        <button type="submit" id="LoadRecordsButton">Lọc dữ liệu</button>
</div>
} 

@section JavaScriptCSSImport{
    <link href="@Url.Content("~/Content/mycontent/list_counter.css")" rel="stylesheet" type="text/css"/>
}

@section JavaScriptDocumentReady{
    $('#danhSachNguoiDung').jtable({
            tableId: "tableNguoiDung",
            title: 'Danh sách người dùng',
            pageSize: 20,
            paging: true,
            sorting: true,
            defaultSorting: 'ThoiGianRao DESC',
            selecting: true, //Enable selecting
            //multiselect: true, //Allow multiple selecting
            //selectingCheckboxes: true, //Show checkboxes on first column
            //selectOnRowClick: false, //Enable this to only select using checkboxes
            actions: {
                listAction: '/Admin/DanhSachTaiKhoan',
                deleteAction: '/Admin/XoaNguoiDung',
                updateAction: '/Admin/CapNhatNguoiDung',
                createAction: '/Admin/ThemNguoiDung'
            },
            fields: {
                ID: {
                    key: true,
                    create: false,
                    edit: false,
                    list: false,
                    sorting: false
                }, 
                IDLoaiTK : {
                    title: 'Loại tài khoản',                   
                    create: true,
                    edit: false,
                    list: false,
                     options:"/Admin/LayDanhSachLoaiTaiKhoan",
                    sorting: false                    
                },   
                IDLoaiTV : {
                    title: 'Loại thành viên',                   
                    create: true,
                    edit: false,
                    list: false,
                     options:"/Admin/LayDanhSachLoaiThanhVien",
                    sorting: false                    
                },  
                  DiaChi: {
                    title: 'Địa chỉ',
                    create: true,
                    edit: true,
                    list: false,
                    sorting: true                    
                },    
                 DiDong: {
                    title: 'Di động',
                    create: true,
                    edit: true,
                    list: false,
                    sorting: true                    
                },    
                DienThoai : {
                    title: 'Điện thoại',
                    create: true,
                    edit: true,
                    list: false,
                    sorting: true                    
                },
               TenDangNhap: {
                    title: 'Tên đăng nhập',
                    create: true,
                    edit: true,
                    list: true,
                    sorting: true                    
                }, 
                MatKhau: {
                    title: 'Mật khẩu',
                    type: 'password',
                    create: true,
                    edit: true,
                    list: false
                },
                HoTen : {
                    title: 'Họ tên',
                    create: true,
                    edit: true,
                    list: true,
                    sorting: true                    
                },  
                GioiTinh: {
                    title: 'Giới tính',
                    width:'10%',
                    create: true,
                    edit: true,
                    list: true,
                    options:{'F':'Nữ', 'M':'Nam'},
                    defaultValue: 'F',
                    type:"radiobutton",
                    sorting: true                    
                },    
                NgaySinh: {
                    title: 'Ngày sinh',
                    type: 'date',
                    displayFormat: 'yy-mm-dd',
                    create: true,
                    edit: true,
                    list: true,
                    sorting: true                
                },  
                Fax : {
                    title: 'Fax',
                    create: true,
                    edit: true,
                    list: false,
                    sorting: true                    
                },
                 Email  : {
                    title: 'Email',
                    create: true,
                    edit: true,
                    list: true,
                    sorting: true                    
                },  
                Xoa: {
                    title: 'Trạng thái',
                    create: false,
                    edit: true,
                    list: true,
                    sorting: true,
                    type: 'checkbox',
                    values: { 'false': 'Hoạt động', 'true': 'Bị xóa' },
                },                
            }
        });

        //Load student list from server
        $('#danhSachNguoiDung').jtable('load');
        //$('table.jtable').css("table-layout","fixed");

        //Filter
        //Re-load records when user click 'load records' button.
        $('#LoadRecordsButton').click(function (e) {
            e.preventDefault();
            $('#danhSachNguoiDung').jtable('load', {
                tenDangNhap: $('#tenDangNhap').val(),
                hoTen: $('#hoTen').val(),
                Email: $('#Email').val(),
                DienThoai: $('#DienThoai').val(),
                loaiThanhVien: $('#loaiThanhVien').val(),
                loaiTaiKhoan: $('#loaiTaiKhoan').val()
            });
        });
       
}

<!-- Container for jTable -->
<div id="danhSachNguoiDung"></div>
